/**
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

 {% from "16.concurrency/03.asynchronous_api/async_api_helper.jinja" import generate_async %}

 {% set cases = [
    {
        'return_type': 'Promise<int>',
        'return_value': 'true'
    },
    {
        'return_type': 'int',
        'return_value': '42'
    },
    {
        'return_type': 'Promise<T>',
        'return_value': 'p',
        'type_parameter': 'U',
        'args': 'p: U',
    },
    {
        'return_type': 'Promise<int> | null',
        'return_value': '42'
    },
    {
        'return_type': '[Promise<string>, Promise<null>]',
        'return_value': '["Hello", null]'
    },
    { 'return_type': 'Promise'},
    { 'return_type': 'Promise<string, int>'},
    { 'return_type': '"Promise<string>"'},
    { 'return_type': 'undefined' },
    { 'return_type': 'Any' }
 ]%}

{% macro generate_complete_test(declaration_type='function') %}
{% for c in cases %}

 /*---
desc: The return type of an async {{declaration_type}} must be Promise<T>.
tags: [compile-only, negative]
---*/

{% set params = {
    'name': 'noParams',
    'body': 'return ' + c.return_value | d(''),
    'return_type': ': ' + c.return_type,
    'class_name': 'AsyncMethodReturnClass',
    'type_parameter': c.type_parameter,
    'args': c.args,
}%}

{{ generate_async(declaration_type, params) }}

function main(){}

{% endfor %}
{% endmacro %}